package com.custom.ipc.reciever;

import javax.portlet.Event;
import javax.portlet.EventRequest;
import javax.portlet.EventResponse;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.bind.annotation.EventMapping;

@Controller
@RequestMapping("VIEW")
public class RecieverController {

	@RequestMapping
	public String doView(RenderRequest request, RenderResponse response) {
		return "reciever";
	}

	@EventMapping(value = "{http://liferay.com/events}ipc.sender")
	public void receiveEvent(EventRequest request, EventResponse response,
			ModelMap map) {

		Event event = request.getEvent();
		String value = (String) event.getValue();
		map.put("sender", value);
		response.setRenderParameter("sender", value);
	}

}
